package com.project.bean.util;

import javax.swing.plaf.PanelUI;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

public class Factory {
    private static Properties pro = new Properties();
    static {
        try {
            pro.load(new FileReader("dao.txt"));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    public static Object getBean(String interfaceName){
        String value = pro.getProperty(interfaceName);

        try {
            Class cla =Class.forName(value);
            return cla.getConstructor().newInstance();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
